﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Economo.Services.BusinessEntities;
using Economo.Services.FaultContracts;
using ServicesTestProject.AccountsServiceReference;


namespace ServicesTestProject
{
    [TestClass]
    public class TestBanks
    {

        //[TestMethod]
        //public void TestGetBanksByDescription_TC_Banks_01()
        //{
        //    ServicesTestProject.AccountsServiceReference.AccountsServiceClient client = new AccountsServiceReference.AccountsServiceClient();
        //    List<Bank> banks = client.GetBanksByDescription(new GetBanksByDescriptionRequest("")).GetBanksByDescriptionResult;
        //    Assert.AreEqual(banks.Count, 7);
        //    List<Bank> Santander = client.GetBanksByDescription(new GetBanksByDescriptionRequest("Santander")).GetBanksByDescriptionResult;
        //    Assert.AreEqual(Santander.Count, 1);
        //    List<Bank> santander = client.GetBanksByDescription(new GetBanksByDescriptionRequest("santander")).GetBanksByDescriptionResult;
        //    Assert.AreEqual(santander.Count, 1);
        //    List<Bank> nada = client.GetBanksByDescription(new GetBanksByDescriptionRequest("nada")).GetBanksByDescriptionResult;
        //    Assert.AreEqual(nada.Count, 0);

            
        //}
        //[TestMethod]
        //public void TestGetBankById_TC_Banks_02()
        //{
        //    ServicesTestProject.AccountsServiceReference.AccountsServiceClient client = new AccountsServiceReference.AccountsServiceClient();            
        //    Bank santander = client.GetBankById(new GetBankByIdRequest(1)).GetBankByIdResult;
        //    Assert.AreEqual(santander.Description, "Santander");
        //    Bank nada = client.GetBankById(new GetBankByIdRequest(150)).GetBankByIdResult ;
        //    Assert.IsNull(nada);
        //}

        //[TestMethod]
        //public void TestUpdateBanks_TC_Banks_03()
        //{
        //    ServicesTestProject.AccountsServiceReference.AccountsServiceClient client = new AccountsServiceReference.AccountsServiceClient();            
            
        //    Bank toUpdate = new Bank();
        //    toUpdate.Id = 3;
        //    toUpdate.Description = "Itaú";            
        //    client.UpdateBank(new UpdateBankRequest(toUpdate));
        //    Bank itau = client.GetBankById(new GetBankByIdRequest(3)).GetBankByIdResult;
        //    Assert.AreEqual(itau.Description, "Itaú");
        //    toUpdate.Description = "Itau";
        //    client.UpdateBank(new UpdateBankRequest(toUpdate));
        //}

        //[TestMethod]
        //public void TestInsertAndDeleteBanks_TC_Banks_04()
        //{
        //    ServicesTestProject.AccountsServiceReference.AccountsServiceClient client = new AccountsServiceReference.AccountsServiceClient();
        //    Int32 preInsert = client.GetBanksByDescription(new GetBanksByDescriptionRequest("")).GetBanksByDescriptionResult.Count;
        //    Bank newBank = new Bank();
        //    newBank.Description = "nuevo";
        //    byte newId = client.InsertBank(new InsertBankRequest(newBank)).InsertBankResult;
        //    Int32 postInsert = client.GetBanksByDescription(new GetBanksByDescriptionRequest("")).GetBanksByDescriptionResult.Count;
        //    Assert.AreEqual(preInsert+1, postInsert);
        //    client.DeleteBankById(new DeleteBankByIdRequest(newId));
        //    Int32 postDelete = client.GetBanksByDescription(new GetBanksByDescriptionRequest("")).GetBanksByDescriptionResult.Count;
        //    Assert.AreEqual(postInsert-1, postDelete);
        //    try
        //    {
        //        client.DeleteBankById(new DeleteBankByIdRequest(150));
        //        Assert.Fail("Wrong Delete didn`t throw an error message");
        //    }
        //    catch 
        //    {
        //        //This delete must fail

        //    }
        //}




    }
    
}
